import Vue from 'vue'
import VueRouter from 'vue-router';

import Login from '../views/Login'
import Home from '../views/Home'
import Register from '../views/Register'
import FrontPage from "@/views/FrontPage"
import Details from "@/views/Details";
import HomeGoods from "@/views/HomeGoods";
import HomePurchase from "@/views/HomePurchase";
import purchaseDetails from "@/views/purchaseDetails";
import HomeKnowledge from "@/views/HomeKnowledge";
import KnowledgeDetail from "@/views/KnowledgeDetail";
import HomeGuide from "@/views/HomeGuide";
import guideDetail from "@/views/guideDetail";
import AllExpert from "@/views/AllExpert";
import question from "@/views/Question";
import appointment from "@/views/Appointment";
import ShopCart from "@/views/ShopCart";
import SmartMatch from "@/views/SmartMatch";
import Financing from "@/views/Financing";
import FinancingDetails from "@/views/FinancingDetails";
import User from '../views/User'
import UserInfo from '../views/UserInfo'
import UserAddress from '../views/UserAddress'
import UserPassword from '../views/UserPassword'
import PublishedGoods from "@/views/PublishedGoods";
import PublishedNeeds from "@/views/PublishedNeeds";
import expertQuestion from "@/views/expertQuestion";
import expertAppoint from "@/views/expertAppoint";
import PublishedKnowledges from "@/views/PublishedKnowledges";
import UserBuy from "@/views/UserBuy";
import UserSell from "@/views/UserSell";
import PublishedGoodsAdmin from "@/views/PublishedGoodsAdmin";
import PublishedNeedsAdmin from "@/views/PublishedNeedsAdmin";
import UserManage from "@/views/UserManage";
import UserFinance from "@/views/UserFinance";
import expertInfo from "@/components/expertInfo";
import PublishNav from '../components/PublishNav.vue';
import PublishGoods from "@/views/PublishGoods";
import PublishNeeds from "@/views/PublishNeeds";
import PublishKnowledges from "@/views/PublishKnowledges";
import userGood from '../views/goodsManager.vue';
import echarts from "@/views/echarts";
import echarts2 from "@/views/echarts2";


Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        component: Home,
        children: [
            {
                path: '',
                redirect: 'front'
            },
            {
                path: 'front',
                component: FrontPage
            },
            {
                path: 'details',
                component: Details
            },
            {
                path: 'goods',
                component: HomeGoods
            },
            {
                path: 'purchase',
                component: HomePurchase
            },
            {
                path: 'purchaseDetails',
                component: purchaseDetails
            },
            {
                path: 'knowledge',
                component: HomeKnowledge
            },
            {
                path: 'knowledge/:id',
                component: KnowledgeDetail
            },
            {
                path: 'guide',
                component: HomeGuide
            },
            {
                path: 'guide/:id',
                component: guideDetail
            },
            {
                path: 'allExpert',
                component: AllExpert
            },
            {
                path: 'question',
                component: question
            },
            {
                path: 'appointment',
                component: appointment
            },
            {
                path: 'shopcart',
                component: ShopCart
            },
            {
                path: 'smartMatch',
                component: SmartMatch
            },
            {
                path: 'financing',
                component: Financing
            },
            {
                path: 'financingDetails',
                component: FinancingDetails
            },
            {
                path: 'user',
                component: User,
                children: [
                    {
                        path: '',
                        redirect: 'userinfo'
                    },
                    {
                        path: 'userinfo',
                        component: UserInfo

                    },
                    {
                        path: 'useraddress',
                        component: UserAddress
                    },
                    {
                        path: 'userpassword',
                        component: UserPassword
                    },
                    {
                        path: 'publishedgoods',
                        component: PublishedGoods
                    },
                    {
                        path: 'publishedneeds',
                        component: PublishedNeeds
                    },
                    {
                        path: 'expertQuestion',
                        component: expertQuestion
                    },
                    {
                        path: 'expertAppoint',
                        component: expertAppoint
                    },
                    {
                        path: 'publishedknowledges',
                        component: PublishedKnowledges
                    },
                    {
                        path: 'userbuy',
                        component: UserBuy
                    },
                    {
                        path: 'usersell',
                        component: UserSell
                    },
                    {
                        path: 'publishedneedsAdmin',
                        component: PublishedNeedsAdmin
                    },
                    {
                        path: 'publishedgoodsAdmin',
                        component: PublishedGoodsAdmin
                    },
                    {
                        path: 'usermanage',
                        component: UserManage
                    },
                    {
                        path: 'userfinance',
                        component: UserFinance
                    },
                    {
                        path: 'expertInfo',
                        component: expertInfo
                    }
                ]
            },
            {
                path:'userGood',
                component:userGood,
                children:[{
                    path: 'publishedgoodsAdmin',
                    component: PublishedGoodsAdmin
                },{
                    path: 'PublishedNeedsAdmin',
                    component: PublishedNeedsAdmin
                },]
            },
            {
                path: 'addmessage',
                component: PublishNav,
                children: [
                    {
                        path: 'publishgoods',
                        component: PublishGoods
                    },
                    {
                        path: 'publishneeds',
                        component: PublishNeeds
                    },
                    {
                        path: 'publishknowledges',
                        component: PublishKnowledges
                    }

                ]
            },
            {
                path: 'usermanage',
                component: UserManage
            },
            {
                path:'echarts',
                component: echarts
            },
            {
                path:'echarts2',
                component: echarts2
            }
        ]
    },
    {
        path: '/login',
        component: Login
    },
    {
        path: '/register',
        component: Register
    }

]

const router = new VueRouter({
    mode: 'history',
    routes
})

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

export default router;